var data_zh = ['你知道吗', '六月', '一日', '星期一', '是', '儿童节'];
var data_en = ['do you know', 'June', 'One day', 'Monday', 'Yes', 'Children\'s day'];
var text2 = document.querySelector("#new");
function zhToEn(e) {
    var text = document.querySelector("#old").value;
    var text1 = document.querySelector("#new").value;
    for (var i = 0; i < data_zh.length; i++) {
        if (text == data_zh[i]) {
            document.querySelector("#new").value = data_en[i];
        } else if (text == data_en[i]) {
            document.querySelector("#new").value = data_zh[i];
        }
    }
}
//按钮
var zh = true;
function res1() {
    var btn1 = document.querySelectorAll('.main .main-left span');
    var btn2 = document.querySelectorAll('.main .main-right span');
    if(zh){
        btn1[0].classList.remove('active');
        btn1[1].classList.add('active');
        btn2[0].classList.remove('active');
        btn2[1].classList.add('active');
    }else {
        btn1[0].classList.add('active');
        btn1[1].classList.remove('active');
        btn2[0].classList.add('active');
        btn2[1].classList.remove('active');
    }
    zh =! zh;

}

function was(){
    var text = document.querySelector("#old").value;
    var btn1 = document.querySelectorAll('.main .main-left span');
    var btn2 = document.querySelectorAll('.main .main-right span');
    for (var l = 0; l < data_en.length; l++){
        if(text == data_en[l]){
            btn1[0].classList.remove('active');
            btn1[1].classList.add('active');
            btn2[0].classList.remove('active');
            btn2[1].classList.add('active');
        }else if(text == data_zh[l]){
            btn1[0].classList.add('active');
            btn1[1].classList.remove('active');
            btn2[0].classList.add('active');
            btn2[1].classList.remove('active');
        }
    }

    if(text != data_zh[0] && text != data_zh[1] && text != data_zh[2] &&
        text != data_zh[3] && text != data_zh[4] && text != data_zh[5] &&
        text != data_en[0] && text != data_en[1] && text != data_en[2] &&
        text != data_en[3] && text != data_en[4] && text != data_en[5]){
        alert("不翻译");
        text2.value ='';
    }
}








